<?php

class Welcome extends Controller {

	function Welcome() {
		parent::Controller();	
	}
	
	function index() {
		if (!$this->session->userdata('username')) {
			$data['isLogin'] = FALSE;
        	redirect("/login", "location");
		} else {
			$data['isLogin'] = TRUE;
			$data['username'] = $this->session->userdata('username');
			$data['role'] = $this->session->userdata('role');
			$data['judul'] = TEKS_HEADER;
			
			
	        $this->load->view('welcome_message',$data);
		}
    }

    function shoutbox(){
        if($this->input->post('proses')){
        if($_POST['nama'] !="" && $_POST['pesan'] != ""){
            $query = "insert into spg_shout_box (nama,pesan) values ('$_POST[nama]','$_POST[pesan]')";
            $this->db->query($query);
        } else{
            echo '<div style="color:#00f; font-size:14px; font-weight:bold;">Ooopsss... masih ada yang belum diisi tuh :D</div>';
        }
    }
 
    $q= $this->db->order_by('id desc')->limit(25)->get("shout_box");

    foreach($q->result() as $rows) {
        echo '<span style="color:#00f; font-size:9px; font-weight:bold;">['.$rows->tgl_pesan.']</span> '.$rows->nama.' : '.$rows->pesan.'<br /><hr />';
    }
    
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */